const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');
const Config = require('../config.js');
const { LOG_LEVEL, getLogger } = require('../logging.js');

const logLevel = Config.LOG_LEVEL;
const awsLogLevel = logLevel === LOG_LEVEL.debug || logLevel === LOG_LEVEL.trace ? LOG_LEVEL.info : LOG_LEVEL.error;
const awsLogger = getLogger(awsLogLevel);

const config = {
  'region': Config.AWS_REGION,
  'logger': awsLogger
};
const client = new DynamoDBClient(config);
const dynamoDBClient = new DynamoDBDocumentClient(client);

exports.dynamoDBClient = dynamoDBClient;
